# Maintainer: Yuta Nakai <nak5124@live.jp>

_realname=l-smash
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgdesc="Loyal to Spec of Mpeg4 and Ad-hoc Simple Hackwork. Yet another opensource mp4 handler (mingw-w64)"
pkgver=2.9.1
pkgrel=3
arch=('any')
url="https://l-smash.github.io/l-smash/"
license=('ISC')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('strip' 'staticlibs')
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/l-smash/l-smash/archive/v${pkgver}.tar.gz"
        '0001-configure-Check-whether-SRCDIR-is-git-repo-or-not.patch'
        '0002-configure-Add-api-version-to-mingw-shared-library-na.patch')
sha256sums=('17f24fc8bffba753f8c628f1732fc3581b80362341274747ef6fb96af1cac45c'
            'de15bb242594b7312187efbd6096f423bdee85b29b878396248c045eec70dbc5'
            'd0a064138b9dbeb50dbfb524b83ed79bbf65d0f9bd4010b96195eb1f009f9948')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-configure-Check-whether-SRCDIR-is-git-repo-or-not.patch
  patch -p1 -i ${srcdir}/0002-configure-Add-api-version-to-mingw-shared-library-na.patch
}

build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  mkdir -p ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --enable-shared

  make ${MAKEFLAGS}
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make DESTDIR=${pkgdir} install

  install -Dm644 ${srcdir}/${_realname}-${pkgver}/LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
